package com.mall.comment.controller;


import com.mall.comment.entity.Comment;
import com.mall.comment.service.CommentService;
import com.mall.commondataformat.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2020-05-05
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
/*
    @Autowired
    private CommentService commentService;

    //查询当前商品评论
    @ApiOperation("查询当前商品评论")
    @GetMapping("/getCommentList")
    public R getCommentList(Long ShangPin_id) {
        List<Comment> list = commentService.list(null);
        Comment comment;
        for(int i=0;i<list.size();i++){
            comment=new Comment();
            comment=list.get(i);
            if(comment.getShangpinId()!=ShangPin_id){
                list.remove(i);
                i=i-1;
            }
        }
        if(list.size()==0){
            return R.ok().message("该商品无评论！");
        }else {
            return R.ok().data("comment", list);
        }
    }
    //增加商品评论
    @ApiOperation("增加商品评论")
    @PostMapping("/addComment")
    public R addComment(long user_id, long ShangPin_id, String content){

        Comment comment=new Comment();
        comment.setUserId(user_id);
        comment.setShangpinId(ShangPin_id);
        comment.setContent(content);

        boolean res=commentService.save(comment);
        if(res){
            return R.ok();
        }
        else{
            return R.error();
        }
    }

*/
}

